package com.ruoyi.stock2.controller;

import java.util.Date;
import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock2.domain.FORERESULTGROUPBYDATE;
import com.ruoyi.stock2.service.IFORERESULTGROUPBYDATEService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 日期分组预测结果Controller
 * 
 * @author ruoyi
 * @date 2019-12-06
 */
@Controller
@RequestMapping("/stock2/FORERESULTGROUPBYDATE")
public class FORERESULTGROUPBYDATEController extends BaseController
{
    private String prefix = "stock2/FORERESULTGROUPBYDATE";

    @Autowired
    private IFORERESULTGROUPBYDATEService fORERESULTGROUPBYDATEService;

    @RequiresPermissions("stock2:FORERESULTGROUPBYDATE:view")
    @GetMapping()
    public String FORERESULTGROUPBYDATE()
    {
        return prefix + "/FORERESULTGROUPBYDATE";
    }

    /**
     * 查询日期分组预测结果列表
     */
    @RequiresPermissions("stock2:FORERESULTGROUPBYDATE:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(FORERESULTGROUPBYDATE fORERESULTGROUPBYDATE)
    {
        startPage();
        List<FORERESULTGROUPBYDATE> list = fORERESULTGROUPBYDATEService.selectFORERESULTGROUPBYDATEList(fORERESULTGROUPBYDATE);
        return getDataTable(list);
    }

    /**
     * 导出日期分组预测结果列表
     */
    @RequiresPermissions("stock2:FORERESULTGROUPBYDATE:export")
    @Log(title = "日期分组预测结果", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(FORERESULTGROUPBYDATE fORERESULTGROUPBYDATE)
    {
        List<FORERESULTGROUPBYDATE> list = fORERESULTGROUPBYDATEService.selectFORERESULTGROUPBYDATEList(fORERESULTGROUPBYDATE);
        ExcelUtil<FORERESULTGROUPBYDATE> util = new ExcelUtil<FORERESULTGROUPBYDATE>(FORERESULTGROUPBYDATE.class);
        return util.exportExcel(list, "FORERESULTGROUPBYDATE");
    }

    /**
     * 新增日期分组预测结果
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存日期分组预测结果
     */
    @RequiresPermissions("stock2:FORERESULTGROUPBYDATE:add")
    @Log(title = "日期分组预测结果", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(FORERESULTGROUPBYDATE fORERESULTGROUPBYDATE)
    {
        return toAjax(fORERESULTGROUPBYDATEService.insertFORERESULTGROUPBYDATE(fORERESULTGROUPBYDATE));
    }


    /* 修改日期分组预测结果
     */
    @GetMapping("/edit/{createdate}")
    public String edit(@PathVariable("createdate") Date createdate, ModelMap mmap)
    {
        mmap.put("createdate", createdate);
        System.out.println(mmap.get("createdate"));
        return prefix + "/edit";
    }

    /* 修改日期分组预测结果
     */
    @GetMapping("/show/{createdate}")
    public String show(@PathVariable("createdate") Date createdate, ModelMap mmap)
    {
        mmap.put("createdate", createdate);
        System.out.println(mmap.get("createdate"));
        return prefix + "/show";
    }

    /**
     * 修改保存日期分组预测结果
     */
    @RequiresPermissions("stock2:FORERESULTGROUPBYDATE:edit")
    @Log(title = "日期分组预测结果", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(FORERESULTGROUPBYDATE fORERESULTGROUPBYDATE)
    {
        return toAjax(fORERESULTGROUPBYDATEService.updateFORERESULTGROUPBYDATE(fORERESULTGROUPBYDATE));
    }

    /**
     * 删除日期分组预测结果
     */
    @RequiresPermissions("stock2:FORERESULTGROUPBYDATE:remove")
    @Log(title = "日期分组预测结果", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(fORERESULTGROUPBYDATEService.deleteFORERESULTGROUPBYDATEByIds(ids));
    }
}
